/**
 * API 统一导出文件
 */

// 人脸识别相关API
export * from './face'

// AI搜题相关API
export * from './tutor'

// OCR识别相关API
export * from './ocr'

// API基础配置
export { default as request } from '@/utils/request'

/**
 * API接口地址配置
 */
export const API_BASE_URL = 'http://localhost:8081'

/**
 * 常用API端点
 */
export const API_ENDPOINTS = {
  // 人脸识别
  FACE_REGISTER: '/fact-info/register',
  FACE_LOGIN: '/fact-info/check',
  FACE_COMPARE: '/fact-info/compare',
  FACE_LIST: '/fact-info/list',
  FACE_DELETE: '/fact-info/delete',
  FACE_UPDATE: '/fact-info/update',
  
  // AI搜题
  SEARCH_BY_IMAGE: '/ai-tutor/search-by-image',
  SEARCH_BY_TEXT: '/ai-tutor/search-by-text',
  AI_CHAT: '/ai-tutor/chat',
  UPLOAD_IMAGE: '/ai-tutor/upload-image',
  OCR_IMAGE: '/ai-tutor/ocr',
  
  // 会话管理
  SESSION_CREATE: '/ai-tutor/session/create',
  SESSION_LIST: '/ai-tutor/session/list',
  SESSION_DETAIL: '/ai-tutor/session',
  SESSION_DELETE: '/ai-tutor/session',
  
  // 错题管理
  WRONG_QUESTION_ADD: '/ai-tutor/wrong-question/add',
  WRONG_QUESTION_LIST: '/ai-tutor/wrong-question/list',
  WRONG_QUESTION_DELETE: '/ai-tutor/wrong-question',
  
  // 统计数据
  STUDY_STATS: '/ai-tutor/stats',
  SEARCH_HISTORY: '/ai-tutor/history',
  SIMILAR_QUESTIONS: '/ai-tutor/similar-questions'
}

/**
 * HTTP状态码
 */
export const HTTP_STATUS = {
  OK: 200,
  CREATED: 201,
  NO_CONTENT: 204,
  BAD_REQUEST: 400,
  UNAUTHORIZED: 401,
  FORBIDDEN: 403,
  NOT_FOUND: 404,
  INTERNAL_SERVER_ERROR: 500
}

/**
 * 业务状态码
 */
export const BUSINESS_CODE = {
  SUCCESS: 200,
  FAIL: 500,
  UNAUTHORIZED: 401,
  FORBIDDEN: 403,
  NOT_FOUND: 404,
  VALIDATION_ERROR: 422
}

/**
 * 文件上传配置
 */
export const UPLOAD_CONFIG = {
  // 支持的图片格式
  ALLOWED_IMAGE_TYPES: ['jpg', 'jpeg', 'png', 'bmp', 'gif'],
  // 最大文件大小 (10MB)
  MAX_FILE_SIZE: 10 * 1024 * 1024,
  // 图片质量
  IMAGE_QUALITY: 0.8,
  // 最大图片尺寸
  MAX_IMAGE_WIDTH: 1920,
  MAX_IMAGE_HEIGHT: 1080
}

/**
 * 人脸识别配置
 */
export const FACE_CONFIG = {
  // 摄像头配置
  CAMERA: {
    WIDTH: 640,
    HEIGHT: 480,
    FACING_MODE: 'user' // 前置摄像头
  },
  // 相似度阈值
  SIMILARITY_THRESHOLD: 0.78,
  // 图片格式
  IMAGE_FORMAT: 'image/jpeg',
  // 图片质量
  IMAGE_QUALITY: 0.8
}

/**
 * AI搜题配置
 */
export const TUTOR_CONFIG = {
  // 聊天配置
  CHAT: {
    MAX_MESSAGE_LENGTH: 1000,
    MAX_HISTORY_COUNT: 50
  },
  // OCR配置
  OCR: {
    SUPPORTED_LANGUAGES: ['zh', 'en'],
    CONFIDENCE_THRESHOLD: 0.8
  },
  // 搜题配置
  SEARCH: {
    MAX_RESULTS: 10,
    SIMILARITY_THRESHOLD: 0.7
  }
}

/**
 * 本地存储键名
 */
export const STORAGE_KEYS = {
  TOKEN: 'token',
  USER_INFO: 'userInfo',
  CHAT_HISTORY: 'chatHistory',
  SEARCH_HISTORY: 'searchHistory',
  SETTINGS: 'settings'
}

/**
 * 错误消息
 */
export const ERROR_MESSAGES = {
  NETWORK_ERROR: '网络连接失败，请检查网络',
  TIMEOUT_ERROR: '请求超时，请稍后重试',
  SERVER_ERROR: '服务器内部错误',
  UNAUTHORIZED: '登录已过期，请重新登录',
  FORBIDDEN: '没有权限访问',
  NOT_FOUND: '请求的资源不存在',
  VALIDATION_ERROR: '数据验证失败',
  CAMERA_ERROR: '无法访问摄像头，请检查权限设置',
  FILE_TYPE_ERROR: '文件类型不支持',
  FILE_SIZE_ERROR: '文件大小超出限制',
  FACE_DETECTION_ERROR: '未检测到人脸，请重新拍照',
  FACE_RECOGNITION_ERROR: '人脸识别失败，请重试'
}

/**
 * 成功消息
 */
export const SUCCESS_MESSAGES = {
  LOGIN_SUCCESS: '登录成功',
  REGISTER_SUCCESS: '注册成功',
  UPLOAD_SUCCESS: '上传成功',
  DELETE_SUCCESS: '删除成功',
  UPDATE_SUCCESS: '更新成功',
  SAVE_SUCCESS: '保存成功',
  FACE_CAPTURE_SUCCESS: '人脸采集成功',
  SEARCH_SUCCESS: '搜题成功'
}
